package com.uinnova.product.eam.base.web.feign;

import com.binary.framework.web.ErrorCode;
import com.binary.framework.web.RemoteResult;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

/**
 * <li>集成基本异常处理
 * 
 * @author XiongJian
 * @since 2020年7月1日上午11:16:20
 *
 */
public abstract class AbsFeignServerControllerAdvice {

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public RemoteResult errorHandler(HttpServletResponse response, Exception ex) {
        RemoteResult result = null;
        result = new RemoteResult(false, ErrorCode.SERVER_ERROR.getCode(), ex.getMessage());
        response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        return result;
    }
}
